package com.cictec.middleware.tde.rm.protocol.rm.decode;

import java.nio.ByteBuffer;

import org.apache.mina.core.session.IoSession;

import com.cictec.middleware.commons.utils.BinaryUtils;
import com.cictec.middleware.tde.exception.MessageDecoderException;
import com.cictec.middleware.tde.rm.protocol.AbstractMessageDecoder;
import com.cictec.middleware.tde.rm.protocol.TerminalMessage;
import com.cictec.middleware.tde.rm.protocol.TerminalMessage.Header;
import com.cictec.middleware.tde.rm.protocol.annotion.TerminalMessageDecoder;
import com.cictec.middleware.tde.rm.protocol.rm.message.Rm0x03TerminalMessage;
import com.cictec.middleware.tde.rm.protocol.rm.utils.RmBinaryUtils;


/**
 *  0x03 上传进出定点数据
 * @author Administrator
 *
 */
@TerminalMessageDecoder(0x03)
public class Rm0x03Decoder extends AbstractMessageDecoder{

	@Override
	public TerminalMessage decode(Header header, ByteBuffer in, IoSession session) throws MessageDecoderException {
		
		Rm0x03TerminalMessage teop=new Rm0x03TerminalMessage(header) ;
		teop.setCreateTime(RmBinaryUtils.dwordToDateRM(in));
		teop.setLat(RmBinaryUtils.dwordToLatLngRM(in));
		teop.setLng(RmBinaryUtils.dwordToLatLngRM(in));
		teop.setSpeed(BinaryUtils.unsignedByteToInt(in));
		teop.setAngle(BinaryUtils.unsignedByteToInt(in));
		teop.setAltitude(BinaryUtils.wordToInt(in));
		teop.setPositionType(BinaryUtils.unsignedByteToInt(in));
		teop.setPositionNumber(BinaryUtils.unsignedByteToInt(in));
		teop.setEnterOutStatus(BinaryUtils.unsignedByteToInt(in));
		teop.setTriggerType(BinaryUtils.unsignedByteToInt(in));
		teop.setGetOnNumber(BinaryUtils.unsignedByteToInt(in));
		teop.setGetOffNumber(BinaryUtils.unsignedByteToInt(in));
		teop.setReserved(BinaryUtils.wordToInt(in));
		
		return teop;
	}

}
